#include <bits/stdc++.h>
using namespace std;

int n,m,r,c;
int arr[105][105];
void out(){
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j)
            cout<<arr[i][j]<<' ';
        cout<<endl;
    }
}

void reshape(){
    if (n*m!=r*c) {
        out();
        return;
    }
    int x=1,y,i=1,j=1;
    while (x++<=r){
        y=1;
        while (y++<=c){
            cout<<arr[i][j]<<' ';
            if (++j>m){
                j=1;
                ++i;
            }
        }
        cout<<endl;
    }
}

int main(){
    cin>>n>>m;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            cin>>arr[i][j];
    cin>>r>>c;
    reshape();
    return 0;
}